<?php
/**
 * Created by PhpStorm.
 * User: 85210755@qq.com
 * NickName: 柏宇娜
 * Date: 2019/5/7 11:50
 */

namespace app;

use think\Cache;
use think\Db;

class Queue
{
    public function __construct()
    {
        //todo
    }

    /**
     * @param $ws
     * @param $frame $frame->data，格式为 [type=>]
     */
    public function handle($ws, $frame)
    {
        //$user = Db::name('user')->where('user_id', 120)->find();
        //$ws->task(['fd' => $frame->fd, 'data' => $user]);
        $data = json_decode($frame->data, true);

        if (is_callable($this->data['type'])) {

            swoole_timer_after($this->data['type'], function () {
                echo "after 3000ms.\n";
            });
        }

    }


}